package com.redshark.wmm;

import java.util.concurrent.ExecutorService;

import com.redshark.wmm.Bluetooth.Bluetooth;

public class MeasurementRequestor implements Runnable {
	// Command Constants
	public static final int DC_VOLTAGE = 64;
	public static final int DC_CURRENT = 65;
	public static final int RESISTANCE = 66;
	public static final int FREQUENCY = 67;
	public static final int DIODE = 68;
	public static final int DEMO = 95;
	public static final int SCOPE_1 = 71; // Need to change these if strings.xml
											// channels ever changed
	public static final int SCOPE_2 = 72;
	public static final int SCOPE_3 = 73;
	public static final int SCOPE_4 = 74;
	public static final int SCOPE_5 = 75;
	
	public static final int CURRENT_SCOPE_LOW = 76;
	public static final int CURRENT_SCOPE_HIGH = 77;
	
	public static final int BATTERY = 80;

	private int type;
	private int cfg;

	public int getCfg() {
		return cfg;
	}

	public void setCfg(int cfg) {
		this.cfg = cfg;
	}

	protected ExecutorService executorService;
	protected Bluetooth bluetooth;

	// Constructor
	MeasurementRequestor(int type, ExecutorService executorService,
			Bluetooth bluetooth) {
		this(type, 0, executorService, bluetooth);
	}

	public MeasurementRequestor(int type, int optCfg,
			ExecutorService executorService, Bluetooth bluetooth) {
		this.type = type;
		this.executorService = executorService;
		this.bluetooth = bluetooth;
		this.cfg = optCfg;

	}

	@Override
	public void run() {
		BluetoothSender bluetoothSender = new BluetoothSender(type, cfg,
				bluetooth);
		executorService.submit(bluetoothSender);
	}

	public boolean isScope() {
		if (type == SCOPE_1 || type == SCOPE_2 || type == SCOPE_3
				|| type == SCOPE_4 || type == SCOPE_5) {
			return true;
		} else {
			return false;
		}
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

}
